package com.example.gray.service;

import com.example.gray.entity.LogDate;
import com.example.gray.entity.LogIp;
import com.example.gray.entity.OpLog;
import com.example.gray.entity.TimeAccess;
import com.example.gray.mapper.OpLogMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Gray 2021/12/28-18:23
 */
@Service
public class OpLogService {
    @Resource
    private OpLogMapper logMapper;

    public PageInfo<OpLog> selectAll(Integer page,Integer size) {
        PageHelper.startPage(page,size);
        List<OpLog> logs = logMapper.getAllLog();
        return new PageInfo<>(logs);
    }
    public List<OpLog> selectAll() {return logMapper.getAllLog();}
    public List<OpLog> selectNew10() {return logMapper.getNew10();}
    public List<OpLog> selectById(Integer id) {return logMapper.getLogById(id);}
    public List<OpLog> selectByIp(String ip) {return logMapper.getLogByIp(ip);}
    public List<OpLog> selectByTime(String S,String E) {return logMapper.getLogByTime(S,E);}
    public List<LogDate> groupByDate(String s,String e){return logMapper.orderByDate(s,e);}
    public List<LogIp> getTop10 (String s,String e){return logMapper.getTop10(s,e);}
    public List<TimeAccess> getTimeZone(){return logMapper.getTimeZone();}
    public Integer insert(OpLog log){return logMapper.insertLog(log);}
    public Integer delete(Integer id){return logMapper.deleteLog(id);}
    public Integer update(OpLog log){return logMapper.updateLog(log);}
}
